<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="Start your development with a Dashboard for Bootstrap 4.">
    <title>不挂高数社区管理页登陆</title>
    <!-- Favicon -->
    <link rel="shortcut icon" href="/favicon.png"/>
    <link rel="bookmark" href="/favicon.png"/>
    <link href="/assets/vendor/nucleo/css/nucleo.css" rel="stylesheet">
    <link href="/assets/vendor/@fortawesome/fontawesome-free/css/all.min.css" rel="stylesheet">
    <!-- Argon CSS -->
    <link type="text/css" href="/assets/css/argon.css?v=1.0.0" rel="stylesheet">
    <script src="/js/jquery-3.4.1.min.js"></script>
</head>

<body class="bg-default">
<div class="main-content">
    <!-- Navbar -->
    <nav class="navbar navbar-top navbar-horizontal navbar-expand-md navbar-dark">
        <div class="container px-5">
            <a class="navbar-brand" href="/">
                <img src="/favicon.png"/>
                <span>不挂高数社区-管理员登陆</span>
            </a>
        </div>
</div>
</nav>

<!-- Header -->
<div class="header bg-gradient-primary py-7 py-lg-7">
    <div class="container">
        <div class="header-body text-center mb-7">
            <div class="row justify-content-center">
                <div class="col-lg-5 col-md-6">
                    <h1 class="text-white">欢迎</h1>
                    <p class="text-lead text-light">进入不挂高数管理系统，请先登陆</p>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- Page content -->
<div class="container mt--8 pb-5">
    <div class="row justify-content-center">
        <div class="col-lg-5 col-md-7">
            <div class="card bg-secondary shadow border-0">

                <div class="card-body px-lg-5 py-lg-5">
                    <form role="form">
                        <div class="form-group mb-3">
                            <div class="input-group input-group-alternative">
                                <div class="input-group-prepend">

                                    <span class="input-group-text"><i class="ni ni-circle-08"></i></span>
                                </div>
                                <input class="form-control" id="login_user" placeholder="管理员(邮箱)" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="input-group input-group-alternative">
                                <div class="input-group-prepend">
                                    <span class="input-group-text"><i class="ni ni-lock-circle-open"></i></span>
                                </div>
                                <input class="form-control" id="login_pwd" placeholder="密码" type="password">
                            </div>
                        </div>

                        <div class="content mt-2">
                            <div class="row">
                                <div class="col">
                                    <a href="javascript:void(0);">
                                        <img id="show-captche" src="/captche/images" onclick="this.src='/captche/images?'+Math.random()"/>
                                    </a>
                                </div>
                                <div class="col">
                                    <div class="form-group">
                                        <div class="input-group input-group-alternative">
                                            <input class="form-control" id="validateCode" autocomplete="off" placeholder="验证码" type="text">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="custom-control custom-control-alternative custom-checkbox">
                            <input class="custom-control-input" id="customCheckLogin" type="checkbox">
                            <label class="custom-control-label" for="customCheckLogin">
                                <span class="text-muted">记住我</span>
                            </label>
                        </div>
                        <div class="text-center">
                            <button type="button" onclick="loginToMainPage()" class="btn btn-primary my-4">登陆</button>
                        </div>
                    </form>
                </div>
            </div>
            <div class="row mt-3">
                <div class="col-6">
                    <a onclick="alert('等待开发！');" class="text-light">
                        <small>忘记密码</small>
                    </a>
                </div>
                <div class="col-6 text-right">

                </div>
            </div>
        </div>
    </div>
</div>
</div>
<!-- Footer -->
<footer class="py-5">
    <div class="container">
        <div class="row align-items-center justify-content-xl-between">
            <div class="col-xl-6">
                <div class="copyright text-center text-xl-left text-muted">
                    &copy; 2019 <a href="/" class="font-weight-bold ml-1"
                                   >不挂高数社区</a>
                </div>
            </div>
            <div class="col-xl-6">
                <ul class="nav nav-footer justify-content-center justify-content-xl-end">
                    <li class="nav-item">
                        <a href="#" class="nav-link"></a>
                    </li>
                    <li class="nav-item">
                        <a href="#" class="nav-link"></a>
                    </li>
                    <li class="nav-item">
                        <a href="#" class="nav-link"></a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</footer>
<!-- Argon Scripts -->
<!-- Core -->

<script src="/resources/js/jquery.cookie.js"></script>

<script src="/assets/vendor/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<!-- Argon JS -->
<script src="/assets/js/argon.js?v=1.0.0"></script>
<script>
    // 登陆
    var loginToMainPage = function () {
        if ($("#login_user").val() == '' || $("#login_pwd").val() == '') {
            alert("请输入用户名或密码");
            return;
        }
        if($("#validateCode").val() == '') {
            alert("验证码不能为空");
            return;
        }
        $.ajax({
            type: 'post',
            url: '/admin/login',
            data: {
                "email": $("#login_user").val(),
                "password": $("#login_pwd").val(),
                "validateCode": $("#validateCode").val()
            },
            success: function (resultdata) {
                if (resultdata.success) {
                    window.location.replace("/admin/main");
                } else {
                    document.getElementById("show-captche").src = this.src='/captche/images?'+Math.random();
                    alert(resultdata.msg);
                }
            }
        })
    };
</script>
</body>

</html>